#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/uaccess.h>

//extern unsigned long kallsyms_lookup_name(const char *name);

static int hello_init(void)
{
    int n;
    char *file = "file";
    asmlinkage long (*sys_creat)(const char __user *pathname, int mode);
    unsigned long (*kallsyms_lookup_name)(const char *name);
    mm_segment_t fs;
    
    fs = get_fs();      // set previous value
    set_fs(get_ds());   // use kernel limit
    kallsyms_lookup_name = 0xc0152ed0;
    sys_creat = kallsyms_lookup_name("sys_creat");
    //sys_creat = 0xc0190130; 
    if (sys_creat <= 0)
    {
        printk("sys_creat is %p\n", sys_creat);
        return 0;
    }
    printk("sys_creat is %p\n", sys_creat);
    n = sys_creat(file, S_IRUSR);
    printk(KERN_ALERT "%d\n", n);

    printk(KERN_ALERT "Hello World!\n");

    set_fs(fs);       // restore before return to user space
    return 0;
}

static void hello_exit(void)
{
    printk(KERN_ALERT "Bye World!\n");
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("xuzhi");
